package com.citcc.api.controller;

import com.citcc.business.bean.vo.CdzStakeVo;
import com.citcc.business.service.CdzStakeService;
import com.citcc.common.page.TableDataInfo;
import com.citcc.framework.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api(tags = "充电桩api")
@RestController
@RequestMapping("/stake")
public class CdzStakeController extends BaseController {

    private final CdzStakeService cdzStakeService;

    public CdzStakeController(CdzStakeService cdzStakeService) {
        this.cdzStakeService = cdzStakeService;
    }

    @ApiOperation("分页获取指定停车场的充电桩列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query"),
            @ApiImplicitParam(name = "orderByColumn", value = "排序列status，1使用中 2空闲", paramType = "query"),
            @ApiImplicitParam(name = "isAsc", value = "desc或者asc", paramType = "query")
    })
    @GetMapping("/v2/list")
    public TableDataInfo getStakeList(@RequestParam String stationId) {
        startPage();
        List<CdzStakeVo> stakeList = cdzStakeService.getStakeListByStationId(stationId);
        return getDataTable(200, stakeList);
    }
    @ApiOperation("分页获取指定停车场的充电枪列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query"),
            @ApiImplicitParam(name = "orderByColumn", value = "排序列status，1使用中 2空闲", paramType = "query"),
            @ApiImplicitParam(name = "isAsc", value = "desc或者asc", paramType = "query")
    })
    @GetMapping("/v2/gunList")
    public TableDataInfo getGunList(@RequestParam String stationId) {
        startPage();
        List<Map<String,Object>> stakeList = cdzStakeService.getGunListByStationId(stationId);
        return getDataTable(200, stakeList);
    }
}
